package com.example.server.controller;

import com.example.server.domain.Dormadmin;
import com.example.server.domain.Students;
import com.example.server.service.DormadminService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

//@CrossOrigin(origins = "*",allowCredentials = "true",allowedHeaders = "*",methods = {RequestMethod.GET,RequestMethod.POST,RequestMethod.DELETE,RequestMethod.PUT,RequestMethod.OPTIONS})
@Controller
@RequestMapping("/dormadmin")
public class DormadminController {
    private final DormadminService dormadminService;

    public DormadminController(DormadminService dormadminService) {
        this.dormadminService = dormadminService;
    }



    @RequestMapping("/create")
    @ResponseBody
    public void createDormadmin(@RequestBody Dormadmin dormadmin) {
        dormadminService.createDormadmin(dormadmin);
    }
    @RequestMapping("/delete")
    @ResponseBody
    public void deleteDormadmin(Long id) {
        dormadminService.deleteDormadmin(id);
    }
    @RequestMapping("/querybyid")
    @ResponseBody
    public Dormadmin getDormadminById(Long id) {
        return dormadminService.getDormadminById(id);
    }
    @RequestMapping("/update")
    @ResponseBody
    public void updateDormadmin(@RequestBody Dormadmin dormadmin) {
        dormadminService.updateDormadmin(dormadmin);
    }
    @RequestMapping("/queryall")
    @ResponseBody
    public List<Dormadmin> getAllDormadmin() {
        return dormadminService.getAllDormadmin();
    }
    @RequestMapping("/querylike")
    @ResponseBody
    public List<Dormadmin> querylike(String dname) {
        return dormadminService.querylike(dname);
    }
}
